package demo02;

import java.util.Random;
import java.util.Scanner;
//猜数字游戏：
//随机生成1-100内的随机数，猜对了，打印恭喜你猜对了
//猜错了，告诉是大了还是小了，直到猜对为止
public class HomeWork02 {
    public static void main(String[] args){
        int randomNumber = new Random().nextInt(100);
        System.out.println("请输入你猜的数字:");
        Scanner sc=new Scanner(System.in);
        int enterNumber = sc.nextInt();
        while(enterNumber!=randomNumber){
            //猜错
            if(enterNumber>randomNumber){
                System.out.println("猜大了，请继续猜下一次");
            }else{
                System.out.println("猜小了，请继续猜下一次");
            }
            System.out.println("请重新输入数字:");
            enterNumber=sc.nextInt();
        }
        System.out.println("恭喜你猜对了");
    }
}